using System;

using libsecondlife;

using Feathertail.Tracker;

namespace Feathertail.Tracker.Filters
{
    public class TypeFilter : ObjectFilter
    {
        public enum ObjectType { Primitive, Avatar };
        private ObjectType _Type;

        public TypeFilter(ObjectType type)
        {
            _Type = type;
        }

        public TypeFilter(ObjectType type, FilterType filter)
        {
            _Type = type;
            _FilterType = filter;
        }



        public override bool IncludeObject(SecondLife Client, LLObject obj)
        {
            switch (_Type)
            {
                case ObjectType.Primitive:
                    if (_FilterType == FilterType.Include)
                    {
                        return (obj is Primitive);
                    }
                    else
                    {
                        return !(obj is Primitive);
                    }
                case ObjectType.Avatar:
                    if (_FilterType == FilterType.Include)
                    {
                        return (obj is Avatar);
                    }
                    else
                    {
                        return !(obj is Avatar);
                    }
            }

            return false;
        }
    }
}
